#include<stdio.h>
#include<assert.h>
#include<string.h>
//char* strncpy_(char* arr1,const char* arr2, int num, int size)
//{
//	assert(arr1 && arr2);
//	if (size < strlen(arr2) + 1)
//		return NULL;
//	while (num--)
//	{
//		*(arr1) = *(arr2);
//		arr1++; arr2++;
//	}
//	return arr1;
//}
//int main()
//{
//	char arr1[20] = "    shirt";
//	char arr2[] = "T - shirt";
//	char* cpy = strncpy_(arr1, arr2, 4,sizeof(arr1));
//	if(cpy !=NULL)
//	printf("%s ", arr1);
//	return 0;
//}


//int strncmp_(const char* arr1, const char* arr2, int num, int size)
//{
//	assert(arr1 && arr2);
//	while (num--&&*arr1==*arr2)
//	{
//		if (*arr1 == '\0')
//			return 0;
//		arr1++;
//		arr2++;
//	}
//	return *arr1 - *arr2;
//
//}
//int main()
//{
//	char arr1[] = "shirt";
//	char arr2[] = "T - shirt";
//	int cmp = strncmp_(arr1, arr2, 4, sizeof(arr1));
//		printf("%d ", cmp);
//	return 0;
//}




char* strstr_(const char* arr1, const char* arr2, int size)
{
	assert(arr1 && arr2);
	const  char* ret = arr1;
	const  char* s1 = arr1;
	const  char* s2 = arr2;
	int len1 = strlen(arr1);
	if (len1 > size)
		return NULL;
	while (*ret)
	{
		s1 = ret;
		s2 = arr2;
		while (*s1 && *s2 && *s1 == *s2)
		{
			s1++; s2++;
		}
		if (*s2 == '\0')
			return (char*)ret;
		ret++;
	}
	return NULL;
}
int main()
{
	char arr1[] = "shirt and shorts,T-shirt and skirt";
	char arr2[] = "and shorts";
	char* str = strstr_(arr1, arr2,sizeof(arr1));
	if (str != NULL)
	printf("%s ",str);
	return 0;
}